package com.hkts.naturalgas.organizational.controller;



    import com.hkts.naturalgas.feign.FeignInterface;
    import com.hkts.naturalgas.organizational.entity.HontUser;
    import com.hkts.naturalgas.organizational.orgVo.UserNameAndPostTitleVo;
    import com.hkts.naturalgas.organizational.service.IHontUserService;
    import org.springframework.web.bind.annotation.*;
    import com.hkts.naturalgas.utils.CustomPageUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.naturalgas.utils.Result;
import com.hkts.naturalgas.utils.ResultUtil;
import com.alibaba.fastjson.JSON;
import org.springframework.ui.Model;
    import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMethod;

    import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author yck
 * @since 2020-12-23
 */
@RestController
@RequestMapping("/performance/hontUser")
public class HontUserController {
private final Logger logger=LoggerFactory.getLogger(HontUserController.class);

@Autowired
public IHontUserService iHontUserService;
    @Autowired
    private FeignInterface feignInterface;

/**
 * 分页查询数据
 *
 * @param page  分页信息
 * @param hontUser 查询条件
 * @return
 */
@ResponseBody
@GetMapping("/getHontUserPageList")
public Result<Object> getHontUserPageList(Page<HontUser> page, HontUser hontUser){
        return ResultUtil.data(CustomPageUtils.getCustomPage(iHontUserService.selectPage(page, hontUser)));
        }
/**
 * 保存和修改公用的
 * @param hontUser 传递的实体
 * @return saveOrUpdate
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/hontUserSave")
public Result<Object> hontUserSave(HontUser hontUser){
        iHontUserService.saveOrUpdate(hontUser);
        return ResultUtil.success("保存成功");
        }

/**
* 根据id获取对象
*
* @param id 实体ID
* @return 0 失败  1 成功
*/
@ResponseBody
@RequestMapping(method = RequestMethod.GET, value = "/hontUserGetById")
public Result<Object> hontUserGetById(String id){
    HontUser byId=iHontUserService.getById(id);
        return ResultUtil.data(byId);
   }

/**
 * 根据id删除对象
 * @param id  实体ID
 * @return 0 失败  1 成功
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/hontUserDelete")
public Result<Object> hontUserDelete(String id){
        iHontUserService.removeById(id);
        return ResultUtil.success("删除成功");
        }
/**
 * 批量删除对象
 * @param item 实体集合ID
 * @return  0 失败  1 成功
 */
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/hontUserBatchDelete")
public Result<Object> deleteBatchIds(String item){
        List<String> ids=(List<String>)JSON.parse(item);
        iHontUserService.removeByIds(ids);
        return ResultUtil.success("删除成功");
        }
    /*
     * 根据用户id 查询当前用户姓名 postTitle
     * */

    @ResponseBody
    @GetMapping("/getHontUserNameAndPostTitle")
    public Result<Object> getHontUserNameAndPostTitle(HontUser hontUser){
        UserNameAndPostTitleVo userNameAndPostTitleVo=iHontUserService.getHontUserNameAndPostTitle(hontUser);
        return ResultUtil.data(userNameAndPostTitleVo);
    }
    /*
    * 处理消息业务
    * 根据流程服务发送过来的参数查找对应user
    * */
    @ResponseBody
    @PostMapping ("/hondlerMessage")
    public Result<Object> hondlerMessage(String params){
        iHontUserService.getMessageRecever(params);
        return ResultUtil.data("");
    }
    @ResponseBody
    @PostMapping ("/testMessage")
    public Result<Object> testMessage(){
        String[] ids= {"ovug85O7d50IvivOiNWxfICV8WpE"};
        feignInterface.send(ids);
        return ResultUtil.data("");
    }

 }
